#pragma once


_JIN_BEGIN


class CWinForm
{
public:
	CWinForm(void);
	virtual ~CWinForm(void);

	operator HWND (void) {
		return m_hWnd;
	}

	BOOL RegisterWindowClass(
		const std::function<void (WNDCLASSEX&)>& = [](WNDCLASSEX&){}
	);
	BOOL CreateWindowForm(
		const std::function<void (CREATESTRUCT&)>& = [](CREATESTRUCT&){},
		const std::function<BOOL (HWND, INT&)>& = [](HWND, INT&)->BOOL{ return TRUE; }
	);
	INT MessageLoop(
		const std::function<void (HWND, LPMSG)>& = [](HWND, LPMSG){ ::Sleep(1); }, 
		const std::function<BOOL (LPMSG)>& = [](LPMSG)->BOOL{ return FALSE; }
	);

	BOOL Move(INT x, INT y) {
		return Move(m_hWnd, x, y);
	}
	BOOL Resize(INT width, INT height) {
		return Resize(m_hWnd, width, height);
	}
	BOOL ChangeWindowStyle(UINT width, UINT height, BOOL wned = False, UINT unstyle = 0) {
		return ChangeWindowStyle(m_hWnd, width, height, wned, unstyle);
	}

	static BOOL Move(HWND, INT x, INT y);
	static BOOL Resize(HWND, INT width, INT height);
	static BOOL ChangeWindowStyle(HWND, UINT width, UINT height, BOOL wned = False, UINT unstyle = 0);

protected:
	HWND			m_hWnd;
	WNDCLASSEX		m_wndClassEx;
	CREATESTRUCT	m_wndStruct;

private:
	static LRESULT WINAPI _WindowProc(HWND, UINT, WPARAM, LPARAM);
};


_JIN_END
